package com.lmk.sc.service;
import java.util.List;
import java.util.Map;

import com.lmk.sc.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import com.lmk.core.web.support.api.RequestResult;
import com.lmk.core.web.support.bean.db.PageParams;
import com.lmk.sc.service.support.FeignUserServiceFallbackFactory;

/**
 * Feign 请求客户端
 * name: 指定服务名称，可以从配置文件注入
 * value: 等价于name
 * url: 手动指定调用地址
 * configuration: Feign配置类，可以自定义Feign的Encoder、Decoder、LogLevel、Contract
 * fallback: 定义容错的处理类，当调用失败时，会调用对应接口的容错逻辑，fallback指定的类必须实现当前标记的接口
 * fallbackFactory: 工厂类，用于生成fallback类示例，通过这个属性我们可以实现每个接口通用的容错逻辑
 * path: 定义当前FeignClient的统一前缀
 *
 * @author LaoMake
 * @email laomake@hotmail.com
 */
@FeignClient(
        name = "UserProvider",
        contextId = "feignUserService",
        path = "/api/user",
        fallbackFactory = FeignUserServiceFallbackFactory.class
)
public interface FeignUserService {

    @GetMapping("")
    List<User> list();

    @GetMapping("/{id}")
    User get(@PathVariable("id") Integer id);

    @PostMapping("")
    Map<String, Object> post(@RequestBody Map<String, Object> entity);

    @PutMapping("")
    Map<String, Object> put(@RequestBody Map<String, Object> entity);

    @DeleteMapping("/{id}")
    Map<String, Object> delete(@PathVariable("id") Integer id);

}
